<template>
  <router-view v-slot="{ Component }">
    <keep-alive :include="cachedComponents">
      <component :is="Component" v-if="Component && isRouterActive" />
    </keep-alive>
  </router-view>
</template>

<script setup lang="ts">
import { computed,provide,nextTick,ref } from 'vue'
import { useRoute } from 'vue-router'

const route = useRoute()
const cachedComponents = computed<any>(() => {
  return [route.name]
})

// 刷新页面
const isRouterActive = ref(true)
provide('reload', () => {
  isRouterActive.value = false
  nextTick(() => {
    isRouterActive.value = true
  })
})

// // 刷新
// import { inject } from 'vue'
// const reload = inject("reload") as any;
</script>

<style scoped lang="scss"></style>
